package com.opi.thread;
import org.apache.log4j.Logger;
import com.opi.bean.NetworkBean;
import com.opi.dao.NetworkDao;
import com.opi.util.CommUtil;
import com.opi.util.ReadScript;

public class NetworkCollectionThread extends Thread{

	private Logger logger = Logger.getLogger(NetworkCollectionThread.class);
	//采样间隔
	private static long sleepTime = 10000; 
			
	public void run(){
		NetworkDao dao = new NetworkDao();
			while(true){
				try {
					Thread.sleep(sleepTime);
				} catch (InterruptedException e) {
					logger.error(e);
				}
				String command = ReadScript.getNetMonitor();
				NetworkBean netBean = CommUtil.getNetInfoToBean(command);
				if(netBean!=null){
					dao.addNetworkInfo(netBean);
				}else{
					logger.info("NetworkCollectionThread:获取网络信息失败!");
				}
			}
	}
	
}
